@extends('default.layouts.adminPublic')
@section('title', '会员套餐管理')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/vip_package')}}">首页</a> &raquo; 会员套餐管理
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->
    <div class="con">
        <div class="conMain">
            <div class="result_wrap">
                <div class="search">
                    <span style="margin-right: 20px;"><a href="{{url('admin/vip_package/create')}}"><i class="fa fa-plus"></i>添加会员套餐</a></span>
                    <span ><a href="{{url('admin/vip_package')}}"><i class="fa fa-recycle"></i>会员套餐列表</a></span>
                </div>
                <div class="message"><p>目前共查找到<strong>{{$vipPackage->total()}}</strong>个套餐记录！且每页显示套餐记录{{$vipPackage->perPage()}}个。</p></div>
            </div>
            <div class="manage">
                @include('flash::message')
            </div>
            <div class="conInfo">
                <form name="thisForm" id="thisForm" action="" method="post">
                    {{csrf_field()}}
                    <div class="conList" id="conList">
                        <dl class="one">
                            <dt><input name="selectall" type="checkbox" value="1" onclick="CheckAll(this)" /></dt>
                            <dd class="vip1">套餐名称</dd>
                            <dd class="vip2">套餐天数</dd>
                            <dd class="vip3">会员简历数</dd>
                            <dd class="vip4">会员职位数</dd>
                            <dd class="vip5">会员积分</dd>
                            <dd class="vip6">非会员简历数</dd>
                            <dd class="vip7">非会员职位数</dd>
                            <dd class="vip8">套餐价格</dd>
                            <dd class="vip9">套餐操作</dd>
                        </dl>
                        @if($vipPackage->count() > 0 )
                            @foreach($vipPackage as $v)
                                <dl id="list{{$v->id}}">
                                    <dt><input name="selected_id[]" type="checkbox" value="{{$v->id}}" /></dt>
                                    <dd class="vip1">{{msubstr($v->vipname,0,8)}}</dd>
                                    <dd class="vip2">{{$v->vip_days}}天</dd>
                                    <dd class="vip3">{{$v->vip_resume_number}}</dd>
                                    <dd class="vip4">{{$v->vip_post_number}}</dd>
                                    <dd class="vip5">{{$v->vip_integral}}</dd>
                                    <dd class="vip6">{{$v->resume_number}}</dd>
                                    <dd class="vip7">{{$v->integral}}</dd>
                                    <dd class="vip8">{{$v->money}}</dd>
                                    <dd class="vip9">
                                        <span><a href="{{url('admin/vip_package/'.$v->id.'/edit')}}">修改套餐</a></span>
                                        <span><a onclick="delPackage({{$v->id}})">删除套餐</a></span>
                                    </dd>
                                </dl>
                            @endforeach
                        @else
                            <div class="nullcon">对不起！没有合同条件的记录！</div>
                        @endif
                        <dl class="last">
                            <dt>
                                <input name="selectall" id="selectall" type="checkbox" value="1" onclick="CheckAll(this)" />
                                <label for="selectall">全选</label>
                            </dt>
                        </dl>
                    </div>
                </form>
                <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                    {!! $vipPackage->links() !!}
                </div>
            </div>

            <div class="stopper" style="margin-top:10px; border-top: 1px solid #e5e5e5"></div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script>
        //全选中与全不选中职位资料
        function CheckAll(form){
            if (form.checked==true){
                for (var i=0;i<document.thisForm.elements.length;i++){
                    var e = document.thisForm.elements[i];
                    if (e.name == 'selectedid' || e.name=='selected_id[]' || e.name=='selectall')
                        e.checked=true;
                }
            }else{
                for (var i=0;i<document.thisForm.elements.length;i++){
                    var e = document.thisForm.elements[i];
                    if (e.name == 'selectedid' || e.name=='selected_id[]' || e.name=='selectall')
                        e.checked=false;
                }
            }
        }
        //删除套餐
        function delPackage(id) {
            layer.confirm('您确定要删除这个套餐吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("{{url('admin/vip_package/')}}/" + id, {'_method': 'delete','_token': "{{csrf_token()}}"}, function (data) {
                    if (data.status == 0) {
                        layer.msg(data.msg, {icon: 6,time:1500});
                        $("#thisForm").find('#conList').find("#list"+id).remove();
                    } else {
                        layer.msg(data.msg, {icon: 5,time:1500});
                    }
                });
            });
        }
    </script>
@endsection